<%-- 
    Document   : getcomments
    Created on : 10 Dec, 2011, 1:42:05 AM
    Author     : Administrator
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*;"%>
<!DOCTYPE html>
<html>
   
    <body>
        <%! String id=null,did=null,user=null,fn=null,ln=null,cdate=null,ctime=null;
        int cid=0;
%>
 <%
 id=(String)session.getAttribute("id");
 did=request.getParameter("q");
 //user=request.getParameter("p");
 if(did==null){
      response.getWriter().write("Error....");
 }
                    Class.forName("com.mysql.jdbc.Driver");
		    Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/kbcssdb","root","mysql");
		    PreparedStatement ps=con.prepareStatement("select * from comments where disid=?");
		    ps.setString(1,did);
                    ResultSet rs=ps.executeQuery();
                    while(rs.next())
                         {
                           user=rs.getString("userid");
                           cid=rs.getInt("commentid");
                           PreparedStatement ps1=con.prepareStatement("select * from userdetails where userid=?");
                           ps1.setString(1, user);
                           ResultSet rs1=ps1.executeQuery();
                           while(rs1.next())
                           {
                              fn=rs1.getString("fname");
                              ln=rs1.getString("lname");
                           }
                         cdate=rs.getString("cmntdate");
                         ctime=rs.getString("cmnttime");
                         response.getWriter().write("<table><tr><td>By"+fn+" "+ln+" on date"+cdate+" "+ctime+"</td></tr>");
                         response.getWriter().write("<p>");
                         response.getWriter().write(rs.getString("cmnt"));
                         response.getWriter().write("</p>");
                         response.getWriter().write("</table>");
                        /* if(user.equals(id))
                          {
                           response.getWriter().write("<td><a href='deletecomments.jsp?id1="+cid+"&id2="+did+"'><img src='delete.png' /></a></td></tr></table>");
                          }*/
                        }
                    
                    
                                       %>
     </body>
</html>
